package base.day12;

public class ArrayToString {
    public static void main(String[] args) {
        int[] array={1,2,3,4,5,6,7,8,9};
       String result=arrTOString(array);
        System.out.println(result);
    }

    public static String arrTOString(int[] array){
        StringBuilder sb=new StringBuilder("[");
        for (int i = 0; i < array.length; i++) {
            if (i==array.length-1){
                sb.append(array[i]).append("]");
            }else {
                sb.append(array[i]).append(", ");
            }
        }
        String st=sb.toString();
        return st;
    }
}
